package com.bkhc.partner.api;

import com.bkhc.common.annotation.ApiOperation;
import com.bkhc.common.annotation.ApiPackage;
import com.bkhc.common.annotation.AuditLog;
import com.bkhc.common.annotation.WebRestController;
import com.bkhc.common.enu.OperationEnum;
import com.bkhc.common.util.ExcelUtil;
import com.bkhc.common.util.response.ResultJson;
import com.bkhc.common.vo.OrderItemVo;
import com.bkhc.common.vo.OrderVo;
import com.bkhc.partner.service.OrderService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;

/**
 * @author pcq
 * @date 2021/6/20 17:57
 */
@WebRestController("")
@Api("订单管理服务")
@RequestMapping("/order")
@ApiPackage(code="order-api",name="订单管理服务",description = "后台订单管理服务操作接口")
public class OrderController extends CommonController{
    private static final Logger logger = LoggerFactory.getLogger(OrderController.class);
    @Autowired
    private OrderService orderSerivce;

    @ApiOperation(code="queryOrder",name="产品合伙人查看转交的订单",description = "产品合伙人查看转交的订单",type = "common")
    @AuditLog(object="Order",operation = "查询订单",type = OperationEnum.query)
    @RequestMapping(path = "list/partner/{pageNum}/{pageSize}",method = RequestMethod.POST)
    public ResultJson<?> getOrders(@RequestBody(required=false) OrderVo order,
                                   @PathVariable(name="pageNum") int pageNum,
                                   @PathVariable(name="pageSize") int pageSize) {
        if(order == null){
            order = new OrderVo();
        }
        ResultJson<?> res = orderSerivce.getOrders(order, pageNum, pageSize);
        return res;
    }
    @ApiOperation(code="updateOrderStatuscomplate",name="厂商确定订单完成",description = "厂商确定订单完成",type = "common")
    @AuditLog(object="Order",operation = "厂商确定订单完成",type = OperationEnum.query)
    @RequestMapping(path = "{orderCode}/complate",method = RequestMethod.POST)
    public ResultJson<?> complateOrder(@PathVariable(name="orderCode") String orderCode
                                  ) {
        ResultJson<?> res = orderSerivce.complateOrder(orderCode);
        return res;
    }

    @ApiOperation(code="updateOrderStatusfail",name="产品合伙人驳回订单",description = "产品合伙人驳回订单",type = "common")
    @AuditLog(object="Order",operation = "产品合伙人驳回订单",type = OperationEnum.query)
    @RequestMapping(path = "{orderCode}/cancel",method = RequestMethod.POST)
    public ResultJson<?> cancelOrder(@PathVariable(name="orderCode") String orderCode
    ) {
        ResultJson<?> res = orderSerivce.cancelOrder(orderCode);
        return res;
    }

}
